package com.maben.s9001.service.impl;

import com.maben.s9001.domain.User;
import com.maben.s9001.repository.UserRepository;
import com.maben.s9001.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户业务类
 */
@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserRepository userRepository;

    @Override
    public List<User> queryUserList() throws Exception {
        return userRepository.findAll();
    }

    @Override
    @Transactional(value = "jpaTransactionManager")
    public void saveUser(User user) throws Exception {
        if (user == null) {
            return;
        }
        userRepository.save(user);
    }
}
